<!-- eslint-disable vue/multi-word-component-names -->
<template>
  <el-dialog title="新增工单" :visible="visible" @close="closeFn">
    <el-form class="form" :rules="formrules" ref="form" :model="form" width="200px">
      <!--               区域名称               -->
      <el-form-item prop="regionName" label="区域名称">
        <el-col :span="19">
          <el-input
            size="medium"
            maxlength="15"
            placeholder="请输入"
            show-word-limit
            v-model="form.regionName"
          ></el-input>
        </el-col>
      </el-form-item>
      <!--            备注            -->
      <el-form-item prop="remark" label="活动名称">
        <el-col :span="19">
          <el-input
            type="textarea"
            :autosize="{ minRows: 3, maxRows: 8 }"
            maxlength="40"
            placeholder="请输入备注不能超过40个字哦"
            show-word-limit
            v-model="form.remark"
          ></el-input>
        </el-col>
      </el-form-item>
    </el-form>

    <div slot="footer" class="dialog-footer">
      <el-button class="btn" @click="closeFn">取 消</el-button>
      <el-button class="btn" type="primary" @click="newCard">确 定</el-button>
    </div>
  </el-dialog>
</template>

<script>
import { pushPointList } from '@/api/point'

export default {
  methods: {
    closeFn () {
      this.$refs.form.resetFields()
      this.$emit('closeFn')
    },
    async newCard () {
      console.log(this.form)
      await pushPointList(this.form).then(() => {
        this.$emit('closeFn')
        this.$refs.form.resetFields()
      }).catch((res) => {
        this.$message(res.response.data)
      })
    }
  },
  props: {
    visible: {
      type: Boolean,
      required: true
    }
  },
  data () {
    return {
      formrules: {
        regionName: [
          { required: true, message: '这玩意儿不能不填呢', trigger: 'blur' }
        ],
        remark: [{ required: true, message: '这个也得填呢', trigger: 'blur' }]
      },
      form: {
        regionName: '',
        remark: ''
      }
    }
  }
}
</script>

<style lang="scss" scoped>
::v-deep .el-dialog {
  border-radius: 25px;
  width: 40%;
  // height: 530px;
}
::v-deep .el-col {
  height: 38px;
  // padding: 15px;
}
::v-deep .el-dialog__body {
  padding: 30px 60px;
}
</style>
